package com.anpy.common.service;

import cn.hutool.core.util.StrUtil;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class BaseController {

    protected final HttpServletRequest request;

    public BaseController(HttpServletRequest request) {
        this.request = request;
    }

    protected Long getUserId() {
        String userId = (String) request.getAttribute("userId");
        if(StrUtil.isNotBlank(userId)){
            return Long.parseLong(userId);
        }
        return 3L;
    }
}